package com.sl.au.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.ReceivedPaymentTotalInfoView;

public interface ReceivedPaymentTotalInfoViewRepository extends JpaRepository<ReceivedPaymentTotalInfoView, String> {

	@Query("select c from ReceivedPaymentTotalInfoView c where c.nBeLeftOverPrice > 0 and (c.sReceivedPaymentsIdentifyNumber like %?1% or c.sReceivedPaymentsCustomerName like %?1% " + 
				" or c.sReceivedPaymentMemo like %?1%) ")
	Page<ReceivedPaymentTotalInfoView> getPage(String key, Pageable pageable);

	@Query("select count(*) from ReceivedPaymentTotalInfoView c where c.nBeLeftOverPrice > 0 and (c.sReceivedPaymentsIdentifyNumber like %?1% or c.sReceivedPaymentsCustomerName like %?1% or c.sReceivedPaymentMemo like %?1%) ")
	long getCount(String key);

	@Query("select c from ReceivedPaymentTotalInfoView c where (c.sReceivedPaymentsIdentifyNumber like %?1% or c.sReceivedPaymentsCustomerName like %?1% " + 
			" or c.sReceivedPaymentMemo like %?1%) ")
	Page<ReceivedPaymentTotalInfoView> getPage1(String key, Pageable pageable);

	@Query("select count(*) from ReceivedPaymentTotalInfoView c where (c.sReceivedPaymentsIdentifyNumber like %?1% or c.sReceivedPaymentsCustomerName like %?1% or c.sReceivedPaymentMemo like %?1%) ")
	long getCount1(String key);

}
